Total Complexity | 1 |
Total Lines | 21 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | import { Controller, Inject, UseGuards, Get, Query } from '@nestjs/common'; |
||
11 | |||
12 | @Controller('events') |
||
13 | @ApiTags('Calendar') |
||
14 | @ApiBearerAuth() |
||
15 | @UseGuards(AuthGuard('bearer'), RolesGuard) |
||
16 | export class GetEventsAction { |
||
17 | constructor( |
||
18 | @Inject('IQueryBus') |
||
19 | private readonly queryBus: IQueryBus |
||
20 | ) {} |
||
21 | |||
22 | @Get() |
||
23 | @Roles(UserRole.PHOTOGRAPHER) |
||
24 | @ApiOperation({ summary: 'Get events by a range of dates' }) |
||
25 | public async index( |
||
26 | @Query() { fromDate, toDate }: EventPeriodDTO, |
||
27 | ): Promise<EventView> { |
||
28 | return await this.queryBus.execute( |
||
29 | new GetEventsByPeriodQuery( |
||
30 | new Date(fromDate), |
||
31 | new Date(toDate) |
||
32 | ) |
||
36 |